﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace System.Web.Mvc
{
    /// <summary>
    /// 上传控件
    /// </summary>
    public static class UploadHelper
    {
        public static MvcHtmlString Uploader(this HtmlHelper helper, string name, string FUNC_onUploadSuccess)
        {
            string str = @"

<link href=""../../Helper/uploadify/uploadify.css"" rel=""stylesheet"" />
<script src=""../../Helper/uploadify/jquery.uploadify.min.js""></script>

<script type=""text/javascript"">
       $(function () {
            $('#" + name + @"').uploadify({
                'buttonText': '上传附件',
                 //'buttonClass': 'browser',
                'removeCompleted': true,
                'multi': false,
                'swf': '/Helper/uploadify/uploadify.swf',
                'uploader': '/Upload/Upload',
                'onUploadSuccess': " + FUNC_onUploadSuccess + @"
            });
        });
</script>

<input type=""file"" name=""upload"" id=""" + name + @""" />
";

            return MvcHtmlString.Create(str);
        }
    }
}